% for given wage level and long-run (stationary)unemployment status value,
% calculate the stream of unemployment benefits for months 1-12 (ALG1)
% and therefore also 
function B0=Calgobm(BMvec,param,wr,xr,fut)
lamNC=param.lamNC(xr);
BM=BMvec(xr);
% difference between B0 in future (fut=1)
% is that there is now no chance of finding job in coal sector
if fut==1
   lamC=0; 
elseif fut==0
    lamC=param.lamC(xr);
end
   % set unemployment benefits - 60% of income in first 12 months
    bm=NaN(13,1);
    for nx=1:Nx
        bm(1:12)=0.6*wr; 
        bm(13)=param.bM;
    end

Bm=NaN(12);
    for tx=1:12
        tosum=NaN(tx,1);
        for sx=0:tx-1
            tosum(sx+1)=((1-lamNC-lamC)./(1+r))^(sx).*((bm(13-(tx-sx))-bm(13))/(1+r));
        end
        Bm(13-tx) = BM + sum(tosum(:));
    end
B0=Bm(1);
end
